package com.fenghuajueli.module_host

import android.os.Bundle
import android.widget.FrameLayout
import com.fenghuajueli.libbasecoreui.BaseApplication
import com.fenghuajueli.libbasecoreui.baseswitch.SwitchKeyV3Helper
import com.fenghuajueli.libbasecoreui.mvp.BaseActivity
import com.fenghuajueli.libbasecoreui.user.UserInfoUtils
import com.fenghuajueli.module_user.network.repository.RefundRepository
import com.sy.module_ad_switch_manager.AdShowHelper
import com.sy.module_ad_switch_manager.AdSwitchManger

/**
 * @Author: sz_ijj
 * @Date: 2024-01-06 14:34
 **/
open class BaseMainActivity : BaseActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        AdSwitchManger.preloadAds(this)
        AdSwitchManger.showSplashEye(this)
        checkAppUpdate()
        RefundRepository.showRefundTipDialog(this)
        //如果是vip并且没有绑定或者激活手机号，则在每次登陆后都要提示绑定或激活手机号
        UserInfoUtils.getInstance().checkOrBindPhone()
        BaseApplication.getApplication().onOpen()
    }

    open fun adBannerView(): FrameLayout? = null

    override fun onResume() {
        super.onResume()
        val vipState = UserInfoUtils.getInstance().isVip()
        val adSwitch = SwitchKeyV3Helper.getAdSwitch()

        AdShowHelper.showInsertAd(
            vipState,
            adSwitch,
            this,
            "NewInteractionAdTag",
            null
        )

        adBannerView()?.let {
            AdShowHelper.showBannerAd(
                vipState,
                adSwitch,
                this,
                it,
                "NewBannerAdTag"
            )
        }
    }
}